package com.neusoft.neuiotms.dcam.common.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractModel;
import com.neusoft.bizcore.web.jpa.model.Comment;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 科技公司位置根节点code=kj <br />
 * 省联社位置根节点code=sl
 * 
 * @author sunchf
 */
@Getter
@Setter
@ToString
@Entity
@org.hibernate.annotations.Table(appliesTo = "neuiot_location", comment = "位置表")
@Table(name = "neuiot_location")
public class Location extends AbstractModel {

    private static final long serialVersionUID = 1L;

    /** 位置名称 */
    @NotBlank(message = "位置名称不能为空")
    @Length(max = 255, message = "位置名称不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '位置名称'")
    private String name;

    /** 位置代码 */
    @NotBlank(message = "位置代码不能为空")
    @Length(max = 255, message = "位置代码不能超过{max}位")
    @Column(length = 255, nullable = false, unique = true)
    @Comment("varchar(255) NOT NULL COMMENT '位置编码'")
    private String code;

    /** 位置顺序 */
    @Column(nullable = false)
    @Comment("int(11) NOT NULL COMMENT '顺序'")
    private int sort = 1;

    @ManyToOne
    private Location parent;
}
